# 内置
# def findDisappearedNumbers(nums):
#     return list(set(range(1, len(nums) + 1)) - set(nums))

# 哈希表
# def findDisappearedNumbers(nums):
#     table = {x: x for x in range(1, len(nums) + 1)}
#     for num in nums:
#         table[num] = -1
#     res = [v for k, v in table.items() if v != -1]
#     return res

# 修改原值
def findDisappearedNumbers(nums):
    n = len(nums)
    for num in nums:
        x = (num - 1) % n
        nums[x] += n

    return [i + 1 for i, num in enumerate(nums) if num <= n]


print(findDisappearedNumbers([4, 3, 2, 7, 8, 2, 3, 1]))
print(findDisappearedNumbers([1, 1]))
